<?php
/**
 * User: Bob
 * Date: 2017/2/14
 * Time: 14:33
 */

namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;

class RabbitProducerController extends Controller
{
    /**
     * @Route("/rabbit/send")
     */
    public function sendAction()
    {
        $msg = array('user_id' => 1235, 'image_path' => '/path/to/new/pic.png');
        //$msg = json_encode($msg_tmp);
        $producer = $this->get('old_sound_rabbit_mq.upload_picture_producer');
        //$producer->setContentType('application/json');
        $producer->publish(serialize($msg));
        return new Response(
            //'<html><body>'.$msg.'</body></html>'
            '<html><body>'.json_encode($msg).'</body></html>'
        );
    }

}